<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /* 
      排列问题用use数组
      */
      var permute = function (nums) {
        const use = []
        const res = []
        function backTracking(path, use) {
          if (path.length == nums.length) {
            return res.push([...path])
          }
          for (let i = 0; i < nums.length; i++) {
            if (!use[i]) {
              use[i] = true
              path.push(nums[i])
              backTracking(path, use)
              path.pop()
              use[i] = false
            }
          }
        }
        backTracking([], use)
        return res
      }
    </script>
  </body>
</html>
